<template>
	<view class="content">
		<view class="contents">
			<view class="contents-one">我的</view>
			<image class="cont-img" :src="userInfo.avatar || '../../static/user-system.png'">
			</image>
			<view class="cont-name">{{userInfo.nickName}}</view>
		</view>
		<view class="cont-editPw">
			<image class="cont-editPw-img1" src="../../static/wode/ix_mima.png"></image>
			<view class="cont-editPw-text" @click="edits">修改密码</view>
			<image class="cont-editPw-img2" src="../../static/wode/ic_return.png"></image>
		</view>
		<view class="cont-editPw" style="margin-top: 0upx;">
			<image class="cont-editPw-img1" src="../../static/wode/ic_tc.png"></image>
			<view class="cont-editPw-text" @click="do_back">退出登录</view>
			<image class="cont-editPw-img2" src="../../static/wode/ic_return.png"></image>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				userInfo: {}
			}
		},
		onLoad() {
			let userInfo = uni.getStorageSync("userInfo")
			this.userInfo = userInfo ? JSON.parse(userInfo) : {};

			// var loginRes = this.checkLogin('../wode/wode', '2');
			// if(!loginRes){return false;}

			// this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				uni.request({
					url: "http://114.215.179.225:9001/yg-account/api/smallProgram/simpleInfo",
					method: "GET",
					success: (res) => {
						let resData = res.data
						console.log(res)

						if (resData.code === 200 && resData.success) {
							this.userInfo = resData.data
						} else {
							uni.showToast({
								title: resData.uiMsg,
								icon: "none",
							});

							this.goLogin()
						}
					}
				})
			},
			do_back() {
				uni.showModal({
					title: '提示',
					content: '确定退出当前账号吗？',
					success: (res) => {
						if (res.confirm) {
							uni.request({
								url: "http://114.215.179.225:9001/yg-account/api/smallProgram/login",
								method: "GET",
								complete: () => {
									this.goLogin()
								},
							})
						}
					}
				});
			},
			goLogin() {
				uni.clearStorageSync('rememberMe')
				uni.clearStorageSync('userInfo')

				uni.reLaunch({
					url: '../login/login'
				});
			},
			edits() {
				uni.navigateTo({
					url: '../editPw/editPw'
				})
			}
		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		height: 100%;
		width: 100%;
		flex-direction: column;
	}

	.contents {
		height: 480upx;
		width: 100%;
		background: #2573B0;
		opacity: 1;
		border-radius: 0px 0px 120upx 120upx;
		position: relative;
	}

	.contents-one {
		width: 68upx;
		height: 48upx;
		font-size: 34upx;
		font-family: PingFang SC;
		font-weight: 500;
		line-height: 48upx;
		position: absolute;
		top: 0;
		right: 0;
		left: 0;
		bottom: 275upx;
		margin: auto;
		color: #FFFFFF;
		opacity: 0.9;
	}

	.cont-img {
		position: absolute;
		top: 0;
		right: 0;
		left: 0;
		bottom: 8upx;
		margin: auto;
		width: 126upx;
		height: 126upx;
		background: rgba(0, 0, 0, 0);
		border: 4upx solid #FFFFFF;
		box-shadow: 0px 6upx 12upx rgba(0, 0, 0, 0.3);
		border-radius: 50%;
		opacity: 1;

	}

	.cont-name {
		position: absolute;
		top: 312upx;
		right: 0;
		left: 0;
		/* bottom: 2upx; */
		margin: auto;
		width: auto;
		height: 50upx;
		font-size: 36upx;
		font-family: PingFang SC;
		font-weight: bold;
		line-height: 50upx;
		color: #FFFFFF;
		opacity: 0.9;
		text-align: center;

	}

	.cont-editPw {
		width: calc(100%-60upx);
		height: 100upx;
		/* position: relative; */
		display: flex;
		opacity: 1;
		border-radius: 16upx;
		margin-left: 30upx;
		margin-right: 30upx;
		background: #FFFFFF;
		margin-top: 60upx;
		margin-bottom: 60upx;
		/* box-shadow: 0 10upx 0 #F5F7F9; */
		box-shadow: 0 0 20rpx #DEE8EC;
	}

	.cont-editPw-img1 {
		height: 28upx;
		width: 24upx;
		/* position: absolute;
			top: 39upx;
			left: 40upx; */
		flex: 0 1 auto;
		margin-top: 39upx;
		margin-left: 40upx;
		/* margin: 32upx 30upx 32upx 40upx; */
	}

	.cont-editPw-text {
		/* width: 112upx; */
		/* position: absolute;
		top: 32upx;
		left: 90upx; */
		flex: 1 1 auto;
		margin-top: 32upx;
		margin-left: 20upx;
		font-size: 28upx;
		height: 40upx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		opacity: 0.9;
	}

	.cont-editPw-img2 {
		height: 22upx;
		width: 14upx;
		/* position: absolute;
			top: 39upx;
			right: 40upx; */
		flex: 0 1 auto;
		margin-top: 39upx;
		margin-right: 40upx;
	}
</style>
